package org.example.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.example.model.User;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
@Api(tags = "管理员API")
public class AdminController {

    @GetMapping("/users")
    @ApiOperation(value = "获取用户列表", notes = "返回所有用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = false, defaultValue = "2", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页大小", required = false, defaultValue = "10", paramType = "query", dataType = "Integer")
    })
    public String getUsers(@RequestParam(required = false, defaultValue = "2") int page,
                           @RequestParam(required = false, defaultValue = "10") int size) {
        return String.format("Users on page %d, size %d", page, size);
    }

    @PostMapping("/user")
    @ApiOperation(value = "创建用户", notes = "创建一个新用户")
    public String createUser(@RequestBody User user) {
        // 用户创建逻辑
        return "User created successfully!";
    }
}
